<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>

<!DOCTYPE HTML>
<html>
	<head>
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">		
		<link href="${pageContext.request.contextPath}/css/globaltd.css"
			rel="stylesheet" type="text/css">
		<script type="text/javascript"
			src="${pageContext.request.contextPath}/js/jquery-1.3.2.js"></script>
		<script type="text/javascript"
			src="${pageContext.request.contextPath}/js/My97DatePicker/WdatePicker.js"></script>
			
		<script type="text/javascript">
        function checkForm(){
        	var title = $("#title").val();
			if(title == null || title ==""){
        		$("#errorMsg").text("请输入选项内容");
        		return false;
        	}else{
        		$("#errorMsg").text();
        		return true;
        	}
        }		
		</script>	
	<body>
		<div class="wrapper">
			<div class="container">
				<div class="nav" id="navText">
					<table border="0" width="100%" cellpadding="0" cellspacing="0">
						<tr>
							<td align="left" width="45%">选项管理:</td>
							<td >
							<c:if test="${max!=1}"><a href="${pageContext.request.contextPath}/toPreOption.action?topicId=${topic.id}" style="font-size: 20px;">上一条</a></c:if>
								&nbsp;&nbsp;
							<c:if test="${min!=1}"><a href="${pageContext.request.contextPath}/toNextOption.action?topicId=${topic.id}" style="font-size: 20px;">下一条</a></c:if>
							</td>
						</tr>
					</table>
					</div>
				<form id="form1" action="${pageContext.request.contextPath}/addAndUpdateOption.action" method="post" onsubmit="return checkForm()">
				<input type="hidden" value="${topic.id}" name="topicId" />
				<input type="hidden" value="${curOption.id}" name="id" />
				<div class="tag">
					<table class="search-tab" cellpadding="0" cellspacing="0">
						<tbody>
							<tr>
								<th>
									选项内容:
								</th>
								<td>
									<input type="text" name="title" id="title" value="${curOption.title}" />
								</td>
								<th>
									是否正确答案
								</th>
								<td>
									<select name="rightFlag">
										<option value="2" <c:if test="${curOption.rightFlag==2}">selected="selected"</c:if>>错误答案</option>
										<option value="1" <c:if test="${curOption.rightFlag==1}">selected="selected"</c:if>>正确答案</option>
									</select>
								</td>
								<td>
								
									<c:choose>
										<c:when test="${curOption.id==0}"><input class="btn" value="新增" id="queryBtn" type="submit">&nbsp;</c:when>
										<c:otherwise><input class="btn" value="更新" id="queryBtn" type="submit">&nbsp;</c:otherwise>
									</c:choose>
								<div id="errorMsg" style="color: red"></div>								
									
								</td>
							</tr>
						</tbody>
					</table>
				</div>
				</form>
				&nbsp;
				<div class="tag">
				<table class="search-tab" cellpadding="0" cellspacing="0">
					<tr class="even">
						<td style="padding-left: 6px;">
							<label for="i4">
								试题标题:
							</label>
						</td>
						<td style="padding-left: 6px;">
							<textarea id="topicTitle" name="topicTitle" rows="3" cols="40">${topic.title}</textarea>
						</td>
					</tr>
					<tr >
						<td style="padding-left: 6px;">
							<label for="i4">
								试题学历
							</label>
						</td>
						<!-- 学院类学历id -->
						<td >
						<c:if test="${topic.gradeType==1}"><!-- 学院类学历id -->			
							<select id="gradeId"  name="gradeId" style="width: 200px;">
								<option value="0" <c:if test="${topic.gradeId==0}" >selected="selected"</c:if>>电影学院学前班${grade10}</option>									
								<option value="1" <c:if test="${topic.gradeId==1}" >selected="selected"</c:if>>电影学院一年级${grade11}</option>									
								<option value="2" <c:if test="${topic.gradeId==2}" >selected="selected"</c:if>>电影学院二年级${grade12}</option>									
								<option value="3" <c:if test="${topic.gradeId==3}" >selected="selected"</c:if>>电影学院三年级${grade13}</option>									
								<option value="4" <c:if test="${topic.gradeId==4}" >selected="selected"</c:if>>电影学院四年级${grade14}</option>									
								<option value="5" <c:if test="${topic.gradeId==5}" >selected="selected"</c:if>>电影学院五年级${grade15}</option>									
								<option value="6" <c:if test="${topic.gradeId==6}" >selected="selected"</c:if>>电影学院六年级${grade16}</option>									
								<option value="7" <c:if test="${topic.gradeId==7}" >selected="selected"</c:if>>电影学院七年级${grade17}</option>									
								<option value="8" <c:if test="${topic.gradeId==8}" >selected="selected"</c:if>>电影学院八年级${grade18}</option>									
								<option value="9" <c:if test="${topic.gradeId==9}" >selected="selected"</c:if>>电影学院九年级${grade19}</option>									
								<option value="10" <c:if test="${topic.gradeId==10}" >selected="selected"</c:if>>电影学院十年级${grade110}</option>									
								<option value="11" <c:if test="${topic.gradeId==11}" >selected="selected"</c:if>>电影学院十一年级${grade111}</option>									
								<option value="12" <c:if test="${topic.gradeId==12}" >selected="selected"</c:if>>电影学院十二年级${grade112}</option>									
								<option value="13" <c:if test="${topic.gradeId==13}" >selected="selected"</c:if>>电影学院大学一年级${grade113}</option>									
								<option value="14" <c:if test="${topic.gradeId==14}" >selected="selected"</c:if>>电影学院大学二年级${grade114}</option>									
								<option value="15" <c:if test="${topic.gradeId==15}" >selected="selected"</c:if>>电影学院大学三年级${grade115}</option>									
								<option value="16" <c:if test="${topic.gradeId==16}" >selected="selected"</c:if>>电影学院大学四年级${grade116}</option>									
								<option value="17" <c:if test="${topic.gradeId==17}" >selected="selected"</c:if>>电影学院大学五年级${grade117}</option>									
								<option value="18" <c:if test="${topic.gradeId==18}" >selected="selected"</c:if>>电影学院大学六年级${grade118}</option>									
								<option value="19" <c:if test="${topic.gradeId==19}" >selected="selected"</c:if>>电影学院研究生一年级${grade119}</option>									
								<option value="20" <c:if test="${topic.gradeId==20}" >selected="selected"</c:if>>电影学院研究生二年级${grade120}</option>									
								<option value="21" <c:if test="${topic.gradeId==21}" >selected="selected"</c:if>>电影学院研究生三年级${grade121}</option>									
								<option value="22" <c:if test="${topic.gradeId==22}" >selected="selected"</c:if>>电影学院博士一年级${grade122}</option>									
								<option value="23" <c:if test="${topic.gradeId==23}" >selected="selected"</c:if>>电影学院博士二年级${grade123}</option>									
								<option value="24" <c:if test="${topic.gradeId==24}" >selected="selected"</c:if>>电影学院博士三年级${grade124}</option>									
								<option value="25" <c:if test="${topic.gradeId==25}" >selected="selected"</c:if>>电影学院教授一年级${grade125}</option>									
								<option value="26" <c:if test="${topic.gradeId==26}" >selected="selected"</c:if>>电影学院教授二年级${grade126}</option>									
								<option value="27" <c:if test="${topic.gradeId==27}" >selected="selected"</c:if>>电影学院教授三年级${grade127}</option>									
							</select>								
					</c:if>
					<c:if test="${topic.gradeType!=1}"><!-- 明星类和电影类学历id -->	
							<select id="gradeId"   name="gradeId" style="width: 200px;">			
								<option value="0" <c:if test="${topic.gradeId==0}" >selected="selected"</c:if>>电影学院小学毕业${grade20}</option>
								<option value="1" <c:if test="${topic.gradeId==1}" >selected="selected"</c:if>>电影学院中学毕业${grade21}</option>
								<option value="2" <c:if test="${topic.gradeId==2}" >selected="selected"</c:if>>电影学院大学毕业${grade22}</option>
								<option value="3" <c:if test="${topic.gradeId==3}" >selected="selected"</c:if>>电影学院硕士毕业${grade23}</option>
								<option value="4" <c:if test="${topic.gradeId==4}" >selected="selected"</c:if>>电影学院博士毕业${grade24}</option>
								<option value="5" <c:if test="${topic.gradeId==5}" >selected="selected"</c:if>>电影学院教授毕业${grade25}</option>
								<!--  <option value="6">电影学院六年级</option>-->
							</select>								
					</c:if>	
						</td>
					</tr>
					<tr class="even">
						<td style="padding-left: 6px;">
							<label for="i4">
								试题类型:
							</label>
						</td>
						<td style="padding-left: 6px;">
							<select id="topicType" name="topicType" >
													<option value="1" <c:if test="${topic.type==1}" >selected="selected"</c:if>>文字</option>
													<option value="2" <c:if test="${topic.type==2}" >selected="selected"</c:if>>图片</option>
													<option value="4" <c:if test="${topic.type==4}" >selected="selected"</c:if>>视频</option>
													<option value="3" <c:if test="${topic.type==3}" >selected="selected"</c:if>>音频</option>
							</select>
						</td>
					</tr>
					<tr class="even">
						<td style="padding-left: 6px;">
							<label for="i4">
								试题备注:
							</label>
						</td>
						<td style="padding-left: 6px;">
							<textarea id="remark" name="remark" rows="3" cols="40">${topic.remark}</textarea>
						</td>
					</tr>
					<tr>
						<td colspan="2">
							<input type="button"  value="更新" onclick="update()">
							&nbsp;							
							<input type="button"  value="删除试题" onclick="removeTopic()">
						</td>
					</tr>
				</table>
				</div>
				<div id="tablePanel">
					<table cellspacing="0" cellpadding="0" even="true" class="list">
						<tbody>
							<tr class="even" style="line-height: 30px;">
								<th class="fi">选项内容</th>
								<th class="fi">是否正确答案</th>
								<th class="fi">试题编号</th>
								<th class="fi" width="15%">试题备注</th>
								<th class="fi">所属专辑</th>
								<th class="fi">试题学历</th>
								<th class="fi">保存时间</th>
								<th class="fi">操作</th>
							</tr>
							<c:forEach items="${dataList}" var="option" varStatus="stat">
								<c:choose>
									<c:when test="${stat.index%2==0}"><tr></c:when>
									<c:otherwise><tr class="even"></c:otherwise>
								</c:choose>	
									<td>${option.title}</td>								
									<td>
										<c:choose>
											<c:when test="${option.rightFlag==1}">正确答案</c:when>
											<c:when test="${option.rightFlag==2}">错误答案</c:when>
											<c:otherwise>未知</c:otherwise>
										</c:choose>
									</td>
									<td>${option.topic.id}&nbsp;</td>
									<td>${option.topic.remark}&nbsp;</td>
									<td>${option.topic.ablum.title}</td>																
									<td>										
										<c:if test="${option.topic.gradeType==1}"><!-- 学院类学历id -->
											<c:choose>
												<c:when test="${option.topic.gradeId==0}">电影学院学前班</c:when>									
												<c:when test="${option.topic.gradeId==1}">电影学院一年级</c:when>									
												<c:when test="${option.topic.gradeId==2}">电影学院二年级</c:when>									
												<c:when test="${topic.gradeId==3}">电影学院三年级</c:when>									
												<c:when test="${option.topic.gradeId==4}">电影学院四年级</c:when>									
												<c:when test="${option.topic.gradeId==5}">电影学院五年级</c:when>									
												<c:when test="${option.topic.gradeId==6}">电影学院六年级</c:when>									
												<c:when test="${option.topic.gradeId==7}">电影学院七年级</c:when>									
												<c:when test="${option.topic.gradeId==8}">电影学院八年级</c:when>									
												<c:when test="${option.topic.gradeId==9}">电影学院九年级</c:when>									
												<c:when test="${option.topic.gradeId==10}">电影学院十年级</c:when>									
												<c:when test="${option.topic.gradeId==11}">电影学院十一年级</c:when>									
												<c:when test="${option.topic.gradeId==12}">电影学院十二年级</c:when>									
												<c:when test="${option.topic.gradeId==13}">电影学院大学一年级</c:when>									
												<c:when test="${option.topic.gradeId==14}">电影学院大学二年级</c:when>									
												<c:when test="${option.topic.gradeId==15}">电影学院大学三年级</c:when>									
												<c:when test="${option.topic.gradeId==16}">电影学院大学四年级</c:when>									
												<c:when test="${option.topic.gradeId==17}">电影学院大学五年级</c:when>									
												<c:when test="${option.topic.gradeId==18}">电影学院大学六年级</c:when>									
												<c:when test="${option.topic.gradeId==19}">电影学院研究生一年级</c:when>									
												<c:when test="${option.topic.gradeId==20}">电影学院研究生二年级</c:when>									
												<c:when test="${option.topic.gradeId==21}">电影学院研究生三年级</c:when>									
												<c:when test="${option.topic.gradeId==22}">电影学院博士一年级</c:when>									
												<c:when test="${option.topic.gradeId==23}">电影学院博士二年级</c:when>									
												<c:when test="${option.topic.gradeId==24}">电影学院博士三年级</c:when>									
												<c:when test="${option.topic.gradeId==25}">电影学院教授一年级</c:when>									
												<c:when test="${option.topic.gradeId==26}">电影学院教授二年级</c:when>									
												<c:when test="${option.topic.gradeId==27}">电影学院教授三年级</c:when>									
												<c:when test="${option.topic.gradeId==28}">电影学院院士</c:when>	
												<c:otherwise>未知</c:otherwise>
											</c:choose>												
										</c:if>
										<c:if test="${option.topic.gradeType!=1}"><!-- 明星类和电影类学历id -->
											<c:choose>
												<c:when test="${option.topic.gradeId==0}">电影学院小学毕业</c:when>
												<c:when test="${option.topic.gradeId==1}">电影学院中学毕业</c:when>
												<c:when test="${option.topic.gradeId==2}">电影学院大学毕业</c:when>
												<c:when test="${option.topic.gradeId==3}">电影学院硕士毕业</c:when>
												<c:when test="${option.topic.gradeId==4}">电影学院博士毕业</c:when>
												<c:when test="${option.topic.gradeId==5}">电影学院教授毕业</c:when>
												<c:when test="${option.topic.gradeId==6}">电影学院六年级</c:when>	
												<c:otherwise>未知</c:otherwise>			
											</c:choose>										
										</c:if>				
									&nbsp;	
									</td>																						
									<td>${option.saveTime}&nbsp;</td>								
									<td>
									<a href="${pageContext.request.contextPath}/removeOption.action?id=${option.id}&topicId=${topic.id}">删除</a>
									&nbsp;
									<a href="${pageContext.request.contextPath}/toAddOption.action?id=${option.id}&topicId=${topic.id}">修改</a>
									</td>								
								</tr>							
							</c:forEach>								
						</tbody>
					</table>				
				</div>
				&nbsp;
				<div class="tag">
				<table class="search-tab" cellpadding="0" cellspacing="0">
					<tr>
						<td>试题内容:</td>
						<td>${topic.title}						
						<c:if test="${topic.title==''||topic.title==null}">
							<c:choose>
								<c:when test="${topic.type==2}">
									<img src="${pageContext.request.contextPath}/uploads/${fn:replace(topic.resourceUrl,'D://resin-pro-3.1.8/webapps/qm/uploads/','')}" />
								</c:when>
								<c:when test="${topic.type==3}">		
								 	<object classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95" id="MediaPlayer1" width="286" height="225">
									　　<param name="AudioStream" value="-1">									
									　　<param name="AutoSize" value="-1">									
									　　<!–是否自动调整播放大小–>									
									　　<param name="AutoStart" value="false">									
									　　<!–是否自动播放–>									
									　　<param name="AnimationAtStart" value="-1">									
									　　<param name="AllowScan" value="-1">									
									　　<param name="AllowChangeDisplaySize" value="-1">									
									　　<param name="AutoRewind" value="0">									
									　　<param name="Balance" value="0">									
									　　<!–左右声道平衡,最左-90,最右90–>									
									　　<param name="BaseURL" value>									
									　　<param name="BufferingTime" value="15">									
									　　<!–缓冲时间–>									
									　　<param name="CaptioningID" value>									
									　　<param name="ClickToPlay" value="-1">									
									　　<param name="CursorType" value="0">									
									　　<param name="CurrentPosition" value="0">									
									　　<!–当前播放进度 -1 表示不变,0表示开头 单位是秒,比如10表示从第10秒处开始播放,值必须是-1.0或大于等于0–>									
									　　<param name="CurrentMarker" value="0">									
									　　<param name="DefaultFrame" value>									
									　　<param name="DisplayBackColor" value="0">									
									　　<param name="DisplayForeColor" value="16777215">									
									　　<param name="DisplayMode" value="0">									
									　　<param name="DisplaySize" value="0">									
									　　<!–视频1-50, 0-100, 2-200,3-全屏 其它的值作0处理,小数则采用四舍五入然后按前的处理–>									
									　　<param name="Enabled" value="-1">									
									　　<param name="EnableContextMenu" value="-1">									
									　　<!-是否用右键弹出菜单控制–>									
									　　<param name="EnablePositionControls" value="-1">									
									　　<param name="EnableFullScreenControls" value="-1">									
									　　<param name="EnableTracker" value="-1">									
									　　<!–是否允许拉动播放进度条到任意地方播放–>									
									　　<param name="Filename" value="${pageContext.request.contextPath}/uploads/${fn:replace(topic.resourceUrl,'D://resin-pro-3.1.8/webapps/qm/uploads/','')}" valuetype="ref">
									
									　　<!–播放的文件地址–>									
									　　<param name="InvokeURLs" value="-1">									
									　　<param name="Language" value="-1">									
									　　<param name="Mute" value="0">									
									　　<!–是否静音–>									
									　　<param name="PlayCount" value="1">									
									　　<!–重复播放次数,0为始终重复–>									
									　　<param name="PreviewMode" value="-1">									
									　　<param name="Rate" value="1">									
									　　<!–播放速率控制,1为正常,允许小数–>									
									　　<param name="SAMIStyle" value>									
									　　<!–SAMI样式–>									
									　　<param name="SAMILang" value>									
									　　<!–SAMI语言–>									
									　　<param name="SAMIFilename" value>									
									　　<!–字幕ID–>									
									　　<param name="SelectionStart" value="-1">									
									　　<param name="SelectionEnd" value="-1">									
									　　<param name="SendOpenStateChangeEvents" value="-1">									
									　　<param name="SendWarningEvents" value="-1">									
									　　<param name="SendErrorEvents" value="-1">									
									　　<param name="SendKeyboardEvents" value="0">									
									　　<param name="SendMouseClickEvents" value="0">									
									　　<param name="SendMouseMoveEvents" value="0">									
									　　<param name="SendPlayStateChangeEvents" value="-1">									
									　　<param name="ShowCaptioning" value="0"> <!–是否显示字幕,为一块黑色,下面会有一大块黑色,一般不显示–>									
									　　<param name="ShowControls" value="-1">									
									　　<!–是否显示控制,比如播放,停止,暂停–>									
									　　<param name="ShowAudioControls" value="-1">									
									　　<!–是否显示音量控制–>									
									　　<param name="ShowDisplay" value="0">									
									　　<!–显示节目信息,比如版权等–>									
									　　<param name="ShowGotoBar" value="0">									
									　　<!–是否启用上下文菜单–>									
									　　<param name="ShowPositionControls" value="-1">									
									　　<!–是否显示往前往后及列表,如果显示一般也都是灰色不可控制–>									
									　　<param name="ShowStatusBar" value="-1">									
									　　<!–当前播放信息,显示是否正在播放,及总播放时间和当前播放到的时间–>									
									　　<param name="ShowTracker" value="-1">									
									　　<!–是否显示当前播放跟踪条,即当前的播放进度条–>									
									　　<param name="TransparentAtStart" value="-1">									
									　　<param name="VideoBorderWidth" value="0">									
									　　<!–显示部的宽部,如果小于视频宽,则最小为视频宽,或者加大到指定值,并自动加大高度.此改变只改变四周的黑框大小,不改变视频大小–>									
									　　<param name="VideoBorderColor" value="0">									
									　　<!–显示黑色框的颜色, 为RGB值,比如ffff00为黄色–>									
									　　<param name="VideoBorder3D" value="0">									
									　　<param name="Volume" value="0">									
									　　<!–音量大小,负值表示是当前音量的减值,值自动会取绝对值,最大为0,最小为-90–>									
									　　<param name="WindowlessVideo" value="0">									
									　　<!–如果是0可以允许全屏,否则只能在窗口中查看–>									
									　　</object>	
									</c:when>
									<c:when test="${topic.type==4}">		
<object CLASSID="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="520" height="356" CODEBASE="http://www.apple.com/qtactivex/qtplugin.cab">
<param name="src" value="${pageContext.request.contextPath}/uploads/${fn:replace(topic.resourceUrl,'D://resin-pro-3.1.8/webapps/qm/uploads/','')}">
<param name="autoplay" value="false">
<param name="loop" value="false">
<param name="CONTROLS" value="CONSOLE">
<embed src="${pageContext.request.contextPath}/uploads/${fn:replace(topic.resourceUrl,'D://resin-pro-3.1.8/webapps/qm/uploads/','')}" width="420" height="256" autoplay="true" loop="true" CONTROLS="CONSOLE" pluginspage="http://www.apple.com/quicktime/"></embed>
</object>													
								</c:when>
								<c:otherwise>
								${topic.title} 
								</c:otherwise>
							</c:choose>
							
						</c:if>
						
						</td>
					</tr>
				</table>
				</div>
			</div>
		</div>
	</body>
<script>
	var webContext = "${pageContext.request.contextPath}";

		function update(){
			var topicId = ${topic.id};
			var gradeId = $("#gradeId").val();
			var remark = $("#remark").val();			
			var topicType = $("#topicType").val();			
			var topicTitle = $("#topicTitle").val();			
			$.ajax({
				type:"post",
				url:webContext+"/doUpdateTopic.action",
				dataType:"json",
				data:{topicTitle:topicTitle,gradeId:gradeId,remark:remark,topicId:topicId,topicType:topicType},
				success:function(data){
					if(data.success=="true"){
						window.location.reload();
					}else{
						alert("保存失败，请联系管理员");
					}
				},
				error:function(){
					alert("保存失败，请联系管理员!");
				}
			});
		}
		function removeTopic(){
			var topicId = ${topic.id};	
			$.ajax({
				type:"post",
				url:webContext+"/removeTopic2.action",
				dataType:"json",
				data:{id:topicId},
				success:function(data){
					if(data.success=="true"){
						alert("操作成功");
						window.location.href=webContext+"/toNextOption.action?topicId="+topicId;
					}else{
						alert("保存失败，请联系管理员");
					}
				},
				error:function(){
					alert("操作成功");
					window.location.href=webContext+"/toNextOption.action?topicId="+topicId;
				}
			});
		}
		
		function imageDisplay(){
			var imageUrl = $("#resourceUrl").val();
			$("#imageDisplayArea").html("<img width=\"200\" height=\"160\" src="+webContext+"/imageDisplay.action?imageUrl="+imageUrl+" />");
		}
    </script>
</html>